package com.hb.bussiness.enums;

import java.util.Objects;

public enum ErrorCodeEnum {
    SUCCESS(200, "成功"),
    FAIL(500, "系统异常,请联系管理员"),
    PHONE_NUMBER_NOT_EMPTY(501, "手机号不能为空"),
    MYSQL_SQL_NOT_EMPTY(502, "sql不能为空"),
    MYSQL_SQL_EXECUTE_FAIL(503, "sql执行失败,请求参数:"),
    REDIS_KEY_NOT_EMPTY(504, "redis key不能为空"),
    REDIS_VALUE_NOT_EMPTY(505, "redis value不能为空"),
    REDIS_EXPIRE_TIME_NOT_NULL(506, "redis key过期时间不能为空"),
    REDIS_EXPIRE_TIMEUNIT_NOT_NULL(507, "redis key过期时间单位不能为空"),
    REDIS_COMMAND_EXECUTE_FAIL(508, "redis执行错误,请求参数:"),
    GATEWAY_REQUEST_METHOD_NOT_SUPPORT(509, "请求方式不支持"),
    GATEWAY_POST_REQUEST_PARAM_ERROR(510, "post请求参数解析异常"),
    GATEWAY_REQUEST_ROUTE_ERROR(511, "http请求异常");


    private Integer code;
    private String msg;

    private ErrorCodeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ErrorCodeEnum getByMessage(String message) {
        ErrorCodeEnum[] errorCodeEnums = values();
        ErrorCodeEnum[] var2 = errorCodeEnums;
        int var3 = errorCodeEnums.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            ErrorCodeEnum errorCodeEnum = var2[var4];
            if (Objects.equals(errorCodeEnum.getMsg(), message)) {
                return errorCodeEnum;
            }
        }

        return null;
    }
}
